﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;

namespace SanJ.FreeCare.Organizations
{
    public interface IOrganizationRepository : IRepository<Organization, Guid>
    {
        //获取同一级别的所有机构
        Task<List<Organization>> GetChildrenAsync(Guid? parentId, CancellationToken cancellationToken = default);
        Task<Organization> GetByIdAsync(Guid id, bool isAsNoTracking);

        Task<Organization> GetByAssociatedIdAsync(string hisCode, bool isAsNoTracking);

        Task<Organization> GetByCodeAsync(string code, bool isAsNoTracking);

        Task<Organization> GetHospitalOrgAsync(string code, bool isAsNoTracking);

        /// <summary>
        /// 通过id 获取code
        /// </summary>
        Task<string> GetCodeByIdAsync(Guid id);

        Task<string> GetAssociatedIdByIdAsync(Guid id);

        Task<string> GetCodeByAssociatedIdAsync(string hisCode);

        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="hospitalCode">医院code-急诊系统对应的医院code</param>
        /// <param name="isAsNoTracking"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<List<Organization>> GetListAsync(string code, bool isAsNoTracking = true, CancellationToken cancellationToken = default);

        /// <summary>
        /// 获取以code为开头的所有子级机构
        /// </summary>
        /// <param name="code">机构代码</param>
        /// <param name="parentId">机构父id</param>
        /// <param name="isAsNoTracking"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<List<Organization>> GetAllChildrenWithParentCodeAsync(string code, Guid? parentId, bool isAsNoTracking = true, CancellationToken cancellationToken = default);

        //根据type获取列表
        Task<List<Organization>> GetByTypeAndCodeAsync(string code, string type);


        /// <summary>
        /// 
        /// </summary>
        Task<List<Organization>> GetyByTriageFlagAsync(string code, bool triageFlag);


        /// <summary>
        /// 获取分诊hiscodelist
        /// </summary>
        Task<List<string>> GetHisCodeListByTriageFlagAsync(string code, bool triageFlag);
    }
}
